package com.dmm.vod.service.impl;

import com.dmm.vo.vod.VideoVisitorCountVo;
import com.dmm.vod.entity.VideoVisitor;
import com.dmm.vod.mapper.VideoVisitorMapper;
import com.dmm.vod.service.VideoVisitorService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 视频来访者记录表 服务实现类
 * </p>
 *
 * @author dmm
 * @since 2022-09-11
 */
@Service
public class VideoVisitorServiceImpl extends ServiceImpl<VideoVisitorMapper, VideoVisitor> implements VideoVisitorService {


    //课程数据统计
    @Override
    public Map<String, Object> findCount(Long courseId, String startDate, String endDate) {
        List<VideoVisitorCountVo> videoVisitorVoList =
                baseMapper.findCount(courseId,startDate,endDate);
        //创建map集合
        Map<String,Object> map=new HashMap<>();
        //存放日期
        List<String> list=new ArrayList<>();
        //存放数量
        List<Integer> list1=new ArrayList<>();
        for(VideoVisitorCountVo videoVisitorCountVo : videoVisitorVoList){
            list.add(videoVisitorCountVo.getJoinTime());
            list1.add(videoVisitorCountVo.getUserCount());
        }
        //放到map集合
        map.put("xData", list);
        map.put("yData", list1);
        return map;
    }
}
